import React from "react";
import RadioElement from "../RadioElement";
import InputElement from "../InputElement";
import { update } from "../../services/student";
export default function Update(props) {
    const handleSubmit = async () => {
        console.log(props.student);
        await update(props.student);
        props.show();
    }
    return (
        <div>
            <h2>修改学生</h2>
            <InputElement value={props.student.name} 
            onInput={(e) => props.setStudent({...props.student,name:e.target.value})}>姓名：</InputElement>
            <InputElement value={props.student.age}
            onInput={(e) => props.setStudent({...props.student,age:e.target.value})}
            >年龄：</InputElement>
            <RadioElement name="updateGender" value={props.student.gender}
            onChange={(e) => props.setStudent({...props.student,gender:e.target.value})}
            >性别：</RadioElement>
            <input type="button" value="修改" onClick={handleSubmit} />
        </div>
    );
}
